function tofindHtgls(CertusFormAjax, CertusJsonAjax, $scope) {
    // 合同管理
    var htglColumns = [{
            id: 'contractNo',
            title: '合同编号',
            width: 150,
            type: 'string',
            columnClass: 'text-center',
        },
        {
            id: 'contractName',
            title: '合同名称',
            width: 150,
            type: 'string',
            columnClass: 'text-center',
        }, {
            id: 'proName',
            title: '项目名称',
            // width: 150,
            type: 'string',
            columnClass: 'text-center',
        }, {
            id: 'contractAmout',
            title: '合同金额',
            width: 100,
            type: 'string',
            columnClass: 'text-center',
            resolution: function (value, record, column, grid, dataNo, columnNo) {
                var content = '￥' + value + '元';
                return content;
              }
        }, {
            id: 'contractSignTime',
            title: '合同签订时间',
            width: 100,
            type: 'date',
            columnClass: 'text-center',
            format: 'yyyy-MM-dd',
            otype: 'time_stamp_ms'
        }, {
            id: 'invoiceBuget',
            title: '开票金额',
            width: 100,
            type: 'string',
            columnClass: 'text-center',
            resolution: function (value, record, column, grid, dataNo, columnNo) {
                var content = '￥' + value + '元';
                return content;
              }
        }, {
            id: 'paymentBuget',
            title: '已收款',
            width: 100,
            type: 'string',
            columnClass: 'text-center',
        }, {
            id: 'sypmBuget',
            title: '未收款',
            width: 100,
            type: 'string',
            columnClass: 'text-center',
        }, {
            id: 'operation',
            title: '操作',
            width: 130,
            type: 'string',
            columnClass: 'text-center',
            resolution: function (value, record, column, grid, dataNo, columnNo) {
                var content = '';
                content += '<button class="btn btn-xs btn-primary" onclick="checkDetail(\'' + record.contractNo + '\')" data-toggle="modal" href="#myModal"><i class="icon-eye-open"></i>  明细</button>';
                // content += '  ';
                // content += '<button class="btn btn-xs btn-info" onclick="editHtgl(' + record.id + ')"><i class="icon-cloud-download"></i>  下载</button>';
                content += '  ';
                content += '<button class="btn btn-xs btn-default" onclick="editHtgl(\'' + record.contractNo + '\')"><i class="icon-gear (alias)"></i>  管理</button>';
                return content;
            }
        }
    ];
    $(".searchparam").on('click', function () {
        $("#htglContainer").empty();
        $("#htglToolBarContainer").empty();
        CertusJsonAjax.dataInit("findBugetInfos", {
            "param": $("#searchParam").val()
        }, htglColumns, 'htglContainer', 'htglToolBarContainer');
    })

    $(".searchparam").click();
    this.checkDetail = function (contractNo) {
        CertusFormAjax.ajax("findBugetDetail", {
            "contractNo": contractNo
        }, function (response) {
            var data = response.data;
            $scope.contractNo = data.contractNo;
            $scope.contractName = data.contractName;
            $scope.proName = data.proName;
            $scope.cusName = data.cusName;
            $scope.contractSignTime = data.contractSignTime;
            $scope.contractNumber = data.contractNumber;
            $scope.contractSigner = data.contractSigner;
            $scope.createUser = data.createUser;
            if (data.isWinning == "0") {
                $scope.isWinning = "无";
            } else {
                $scope.isWinning = "有"
            }
            $scope.softIncome = data.softIncome;
            $scope.notSoftIncome = data.notSoftIncome;
            $scope.contractAmount = data.contractAmout;
            $scope.invoiceBuget = data.invoiceBuget;
            $scope.syKpBuget = data.syKpBuget;
            $scope.paymentBuget = data.paymentBuget;
            $scope.sypmBuget = data.sypmBuget;
            $scope.keyTerms = data.keyTerms;
            $scope.applyInstruction = data.applyInstruction;
        });
        // 开票信息
        var plistColumns = [{
            id: 'invoice_buget',
            title: '开票金额',
            width: 150,
            type: 'string',
            columnClass: 'text-center',
            resolution: function (value, record, column, grid, dataNo, columnNo) {
                var content = '￥' + value + '元';
                return content;
              }
        }, {
            id: 'user_name',
            title: '开票人',
            width: 75,
            type: 'string',
            columnClass: 'text-center',
        }, {
            id: 'invoice_time',
            title: '开票时间',
            width: 90,
            type: 'date',
            format: 'yyyy/MM/dd',
            otype: 'time_stamp_ms',
            columnClass: 'text-center',
        }, {
            id: 'invoice_comments',
            title: '发票内容',
            type: 'string',
            columnClass: 'text-left',
        }, {
            id: 'invoice_sl',
            title: '税率',
            width: 50,
            type: 'string',
            columnClass: 'text-center',
            resolution: function (value, record) {
                return record.invoice_sl + "%";
            }
        }];
        CertusFormAjax.ajax("findHtglInvos", {
            "contractId": contractNo
        }, function (response) {
            $("#plistContainer1").empty();
            var plistOption = {
                lang: 'zh-cn',
                ajaxLoad: false,
                extraWidth: 20,
                // loadURL:'url',
                exportFileName: '开票信息',
                datas: response.data,
                columns: plistColumns,
                gridContainer: 'plistContainer1',
                tools: ''
            };
            var plistGrid = $.fn.dlshouwen.grid.init(plistOption);
            plistGrid.load();
        })

        // 回款信息
        var recbleColumns = [{
            id: 'payment_buget',
            title: '回款金额',
            width: 150,
            type: 'string',
            columnClass: 'text-center',
            resolution: function (value, record, column, grid, dataNo, columnNo) {
                var content = '￥' + value + '元';
                return content;
              }
        }, {
            id: 'user_name',
            title: '经办人',
            width: 75,
            type: 'string',
            columnClass: 'text-center',
        }, {
            id: 'payment_time',
            title: '回款日期',
            width: 90,
            columnClass: 'text-center',
            type: 'date',
            format: 'yyyy/MM/dd',
            otype: 'time_stamp_ms'
        }, {
            id: 'payment_comments',
            title: '回款说明',
            type: 'string',
            columnClass: 'text-left',
        }];

        CertusFormAjax.ajax("findHtglPayments", {
            "contractId": contractNo
        }, function (response) {
            $("#recbleContainer1").empty();
            var recbleOption = {
                lang: 'zh-cn',
                ajaxLoad: false,
                extraWidth: 20,
                // loadURL:'url',
                exportFileName: '回款信息列表',
                datas: response.data,
                columns: recbleColumns,
                gridContainer: 'recbleContainer1',
                tools: '',
            };
            var recbleGrid = $.fn.dlshouwen.grid.init(recbleOption);
            recbleGrid.load();
        });

        // 验收报告
        var recaColumns = [{
            id: 'contractId',
            title: '合同编号',
            type: 'string',
            columnClass: 'text-center',
        }, {
            id: 'acceptanceType',
            title: '类型',
            width: 75,
            type: 'string',
            columnClass: 'text-center',
        }, {
            id: 'customerName',
            title: '签字人',
            width: 75,
            type: 'string',
            columnClass: 'text-center',
        }, {
            id: 'acceptanceTime',
            title: '验收日期',
            width: 90,
            type: 'date',
            format: 'yyyy/MM/dd',
            otype: 'time_stamp_ms',
            columnClass: 'text-center',
        }, {
            id: 'acceptanceResult',
            title: '验收结果',
            width: 75,
            type: 'string',
            otype: 'time_stamp_ms',
            columnClass: 'text-center',
        }, {
            id: 'acceptanceComments',
            title: '说明',
            // width: 150,
            type: 'string',
            columnClass: 'text-left',
            // hideType: 'lg|md|sm|xs'
        }];
        $("#ysContainer1").empty();
        CertusFormAjax.ajax("findAccetpancesByConId", {
            "contractId": contractNo
        }, function (response) {
            var recaOption = {
                lang: 'zh-cn',
                ajaxLoad: false,
                extraWidth: 20,
                // loadURL:'url',
                exportFileName: '验收信息列表',
                datas: response.data,
                columns: recaColumns,
                gridContainer: 'ysContainer1',
                tools: ''
            };
            var recaGrid = $.fn.dlshouwen.grid.init(recaOption);
            recaGrid.load();
        });
    }
}

// 合同管理
function editHtgl(contractNo) {
    location.href = '#/tohtgl/' + contractNo;
}

// // 统计数据
// var tlistColumns = [ {
//   id: 'filenav',
//   title: '合同金额',
//   width: 150,
//   type: 'string',
//   columnClass: 'text-center',
// }, {
//   id: 'fple',
//   title: '开票金额',
//   width: 150,
//   type: 'string',
//   columnClass: 'text-center',
// }, {
//   id: 'fileName',
//   title: '剩余开票金额',
//   width: 150,
//   type: 'string',
//   columnClass: 'text-center',
// }, {
//   id: 'filemsg',
//   title: '已收款',
//   width: 150,
//   type: 'string',
//   columnClass: 'text-left',
// }, {
//   id: 'filelv',
//   title: '未收款',
//   width: 150,
//   type: 'string',
//   columnClass: 'text-center',
// }, ];
// var tlistOption = {
//   lang: 'zh-cn',
//   ajaxLoad: false,
//   // loadURL:'url',
//   exportFileName: '统计数据',
//   datas: [{
//     id: 1,
//     filenav: '￥999,999,999.00元',
//     fple: '￥999,999,999.00元',
//     fileName: '￥999,999,999.00元',
//     filemsg: '￥999,999,999.00元',
//     filelv: '￥999,999,999.00元',
//   }, ],
//   columns: tlistColumns,
//   gridContainer: 'tlistContainer',
//   toolbarContainer: 'tlistToolBarContainer',
//   tools: '',
//   pageSize: 10,
//   pageSizeLimit: [10, 15, 20]
// };
// var tlistGrid = $.fn.dlshouwen.grid.init(tlistOption);
// $(function () {
//   tlistGrid.load();
// });
function tofindlists(CertusFormAjax, $routeParams, $scope) {

    // 开票信息
    var plistColumns = [{
        id: 'invoice_buget',
        title: '开票金额',
        width: 150,
        type: 'string',
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var content = '￥' + value + '元';
            return content;
          }
    }, {
        id: 'user_name',
        title: '开票人',
        width: 75,
        type: 'string',
        columnClass: 'text-center',
    }, {
        id: 'invoice_time',
        title: '开票时间',
        width: 100,
        type: 'date',
        format: 'yyyy-MM-dd',
        otype: 'time_stamp_ms',
        columnClass: 'text-center',
    }, {
        id: 'invoice_comments',
        title: '发票内容',
        type: 'string',
        columnClass: 'text-left',
    }, {
        id: 'invoice_sl',
        title: '税率',
        width: 50,
        type: 'string',
        columnClass: 'text-center',
        resolution: function (value, record) {
            return record.invoice_sl + "%";
        }
    }];
    CertusFormAjax.ajax("findHtglInvos", {
        "contractId": $routeParams.cid
    }, function (response) {
        var plistOption = {
            lang: 'zh-cn',
            ajaxLoad: false,
            extraWidth: 20,
            // loadURL:'url',
            exportFileName: '开票信息',
            datas: response.data,
            columns: plistColumns,
            gridContainer: 'plist1Container',
            tools: ''
        };
        var plistGrid = $.fn.dlshouwen.grid.init(plistOption);
        plistGrid.load();
    })

    // 回款信息
    var recbleColumns = [{
        id: 'user_name',
        title: '经办人',
        width: 75,
        type: 'string',
        columnClass: 'text-center',
    }, {
        id: 'payment_buget',
        title: '回款金额',
        width: 150,
        type: 'string',
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var content = '￥' + value + '元';
            return content;
          }
    }, {
        id: 'payment_time',
        title: '回款日期',
        width: 100,
        columnClass: 'text-center',
        type: 'date',
        format: 'yyyy-MM-dd',
        otype: 'time_stamp_ms'
    }, {
        id: 'payment_comments',
        title: '回款说明',
        type: 'string',
        columnClass: 'text-left',
    }];

    CertusFormAjax.ajax("findHtglPayments", {
        "contractId": $routeParams.cid
    }, function (response) {
        var recbleOption = {
            lang: 'zh-cn',
            ajaxLoad: false,
            extraWidth: 20,
            // loadURL:'url',
            exportFileName: '回款信息列表',
            datas: response.data,
            columns: recbleColumns,
            gridContainer: 'recble1Container',
            tools: '',
        };
        var recbleGrid = $.fn.dlshouwen.grid.init(recbleOption);
        recbleGrid.load();
    });

    // 合同信息-统计数据
    var hlistColumns = [{
        id: 'contractNo',
        title: '合同编号',
        type: 'string',
        columnClass: 'text-center',
    }, {
        id: 'contractAmout',
        title: '合同金额',
        width: 150,
        type: 'string',
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var content = '￥' + value + '元';
            return content;
          }
    }, {
        id: 'invoiceBuget',
        title: '开票总金额',
        width: 150,
        type: 'string',
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var content = '￥' + value + '元';
            return content;
          }
    }, {
        id: 'syKpBuget',
        title: '剩余开票金额',
        width: 150,
        type: 'string',
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var content = '￥' + value + '元';
            return content;
          }
    }, {
        id: 'paymentBuget',
        title: '已收款',
        width: 150,
        type: 'string',
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var content = '￥' + value + '元';
            return content;
          }
    }, {
        id: 'sypmBuget',
        title: '未收款',
        width: 150,
        type: 'string',
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var content = '￥' + value + '元';
            return content;
          }
    }];
    CertusFormAjax.ajax("findHtglBugetTjInfo", {
        "contractId": $routeParams.cid
    }, function (response) {
        var hlistOption = {
            lang: 'zh-cn',
            ajaxLoad: false,
            extraWidth: 20,
            // loadURL:'url',
            exportFileName: '合同信息-统计数据',
            datas: response.data,
            columns: hlistColumns,
            gridContainer: 'hlist1Container',
            tools: ''
        };
        var hlistGrid = $.fn.dlshouwen.grid.init(hlistOption);
        hlistGrid.load();
    });
}